import { Color } from 'https://unpkg.com/three/build/three.module.js';
import { initShaders } from '../jsm/Utils.js';
import lib from '../jsm/ThreeLib.js';

window.onload = function () {

    const backColor = new Color("rgba(233,233,233,1)");

    const canvas = document.getElementById("canvas");
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;

    const gl = canvas.getContext("webgl");
    //初始化着色器
    initShaders(gl,
        document.querySelector("#vertexShader").innerText,
        document.querySelector("#fragmentShader").innerText);

    //获取顶点着色器中的变量
    const a_Position = gl.getAttribLocation(gl.program, "a_Position");
    console.log(a_Position);
    //修改顶点着色器中的变量(3f为修改前三个数值)
    gl.vertexAttrib3f(a_Position, -1.0, 1.0, 0.0);


    lib.clearCanvas(gl, backColor)

    gl.drawArrays(gl.POINTS, 0, 1);
}